package com.example.wan_android.adapter

import android.view.ViewGroup
import android.widget.ImageView
import com.example.wan_android.BR
import com.example.wan_android.R
import com.example.wan_android.core.CoreViewHolder
import com.example.wan_android.databinding.AdapterCollectionBinding
import com.example.wan_android.http.bean.CollectionInfoData
import com.example.wan_android.viewmodel.CollectionViewModel

class CollectionAdater(vm: CollectionViewModel) :
    CoreAdapter<AdapterCollectionBinding, CollectionViewModel, CollectionInfoData>(
        BR.data,
        BR.viewModel,
        vm
    ) {
    override fun getItemLayoutId(viewType: Int): Int {
        return R.layout.adapter_collection
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CoreViewHolder {
        val holder = super.onCreateViewHolder(parent, viewType)

        holder.binding.root.findViewById<ImageView>(R.id.iv_love).setOnClickListener {
            val position = holder.adapterPosition
            mViewModel?.unCollection(mListData[position].originId)
        }
        return holder
    }

    override fun onBindViewHolder(holder: CoreViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
    }
}